import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;


public class SubmitBAction implements ActionListener {



    @Override
    public void actionPerformed(ActionEvent e)  {
        if (e.getSource() == TCFrame.submitButton) {
           String userInput = TCFrame.textField.getText();
           Integer answer = Integer.valueOf(userInput);

            File file = new File("./sum/sum.txt");
            try {
                Scanner scanner = new Scanner(file);
                int num = scanner.nextInt();
                if (answer !=num){
                    System.out.println("解密失败");
                }else {
                    LogicHandle.logicDecode();
                    System.exit(0);
                }
                System.out.println("读取到的数字是：" + num);
            } catch (FileNotFoundException ex) {
                throw new RuntimeException(ex);
            } catch (Exception ex) {
                throw new RuntimeException(ex);
            }


            System.out.println("User input: " + answer);
        }
    }
}
